/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ondrej
 */
@Entity
@Table(name = "project")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Project.findAll", query = "SELECT p FROM Project p"),
    @NamedQuery(name = "Project.findById", query = "SELECT p FROM Project p WHERE p.id = :id"),
    @NamedQuery(name = "Project.findByTitle", query = "SELECT p FROM Project p WHERE p.title = :title"),
    @NamedQuery(name = "Project.findByStart", query = "SELECT p FROM Project p WHERE p.start = :start"),
    @NamedQuery(name = "Project.findByEnd", query = "SELECT p FROM Project p WHERE p.end = :end"),
    @NamedQuery(name = "Project.findByAddress", query = "SELECT p FROM Project p WHERE p.address = :address"),
    @NamedQuery(name = "Project.findByHomeFolderPath", query = "SELECT p FROM Project p WHERE p.homeFolderPath = :homeFolderPath"),
    @NamedQuery(name = "Project.findByActiveFrom", query = "SELECT p FROM Project p WHERE p.activeFrom = :activeFrom"),
    @NamedQuery(name = "Project.findByActiveTo", query = "SELECT p FROM Project p WHERE p.activeTo = :activeTo")})
public class Project implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Size(max = 30)
    @Column(name = "title")
    private String title;
    @Column(name = "start")
    private Integer start;
    @Column(name = "end")
    private Integer end;
    @Size(max = 30)
    @Column(name = "address")
    private String address;
    @Size(max = 40)
    @Column(name = "home_folder_path")
    private String homeFolderPath;
    @Column(name = "active_from")
    private Integer activeFrom;
    @Column(name = "active_to")
    private Integer activeTo;
    @OneToMany(mappedBy = "pROJECTid")
    private Collection<Cost> costCollection;
    @JoinColumn(name = "PROJECT_STATUS_id", referencedColumnName = "id")
    @ManyToOne
    private ProjectStatus pROJECTSTATUSid;
    @JoinColumn(name = "EMPLOYEE_id", referencedColumnName = "id")
    @ManyToOne
    private Employee eMPLOYEEid;
    @OneToMany(mappedBy = "pROJECTid")
    private Collection<ContactProject> contactProjectCollection;
    @OneToMany(mappedBy = "pROJECTid")
    private Collection<File> fileCollection;
    @OneToMany(mappedBy = "pROJECTid")
    private Collection<WorkingBlock> workingBlockCollection;

    public Project() {
    }

    public Project(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getStart() {
        return start;
    }

    public void setStart(Integer start) {
        this.start = start;
    }

    public Integer getEnd() {
        return end;
    }

    public void setEnd(Integer end) {
        this.end = end;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getHomeFolderPath() {
        return homeFolderPath;
    }

    public void setHomeFolderPath(String homeFolderPath) {
        this.homeFolderPath = homeFolderPath;
    }

    public Integer getActiveFrom() {
        return activeFrom;
    }

    public void setActiveFrom(Integer activeFrom) {
        this.activeFrom = activeFrom;
    }

    public Integer getActiveTo() {
        return activeTo;
    }

    public void setActiveTo(Integer activeTo) {
        this.activeTo = activeTo;
    }

    @XmlTransient
    public Collection<Cost> getCostCollection() {
        return costCollection;
    }

    public void setCostCollection(Collection<Cost> costCollection) {
        this.costCollection = costCollection;
    }

    public ProjectStatus getPROJECTSTATUSid() {
        return pROJECTSTATUSid;
    }

    public void setPROJECTSTATUSid(ProjectStatus pROJECTSTATUSid) {
        this.pROJECTSTATUSid = pROJECTSTATUSid;
    }

    public Employee getEMPLOYEEid() {
        return eMPLOYEEid;
    }

    public void setEMPLOYEEid(Employee eMPLOYEEid) {
        this.eMPLOYEEid = eMPLOYEEid;
    }

    @XmlTransient
    public Collection<ContactProject> getContactProjectCollection() {
        return contactProjectCollection;
    }

    public void setContactProjectCollection(Collection<ContactProject> contactProjectCollection) {
        this.contactProjectCollection = contactProjectCollection;
    }

    @XmlTransient
    public Collection<File> getFileCollection() {
        return fileCollection;
    }

    public void setFileCollection(Collection<File> fileCollection) {
        this.fileCollection = fileCollection;
    }

    @XmlTransient
    public Collection<WorkingBlock> getWorkingBlockCollection() {
        return workingBlockCollection;
    }

    public void setWorkingBlockCollection(Collection<WorkingBlock> workingBlockCollection) {
        this.workingBlockCollection = workingBlockCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Project)) {
            return false;
        }
        Project other = (Project) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Project[ id=" + id + " ]";
    }
    
}
